<template>
  <a-modal
    title="项目类型"
    :width="800"
    :visible="visible"
    :confirmLoading="loading"
    @ok="() => { $emit('ok') }"
    @cancel="() => { $emit('cancel') }">
    <a-spin :spinning="loading">
      <a-form :form="form" v-bind="formLayout">

        <a-row :gutter="24">
          <a-col :md="12" :sm="12">
            <a-form-item
              label="分包商名称"
              :labelCol="{lg: {span: 7}, sm: {span: 7}}"
              :wrapperCol="{lg: {span:17}, sm: {span: 17} }">
              <BaseInput
                      v-decorator="['subcontractors',{rules: [{ required: true, message: ' ' }]}]"
                      placeholder=" " disabled />
            </a-form-item>
          </a-col>
          <a-col :md="12" :sm="12">
            <a-form-item
                    label="状态"
                    :labelCol="{lg: {span: 7}, sm: {span: 7}}"
                    :wrapperCol="{lg: {span:17}, sm: {span: 17} }">
              <a-select  v-decorator="['statusCode',{rules: [{  message: ' ' }]}]" placeholder="请选择"
                         default-value="0">
                <a-select-option  value="0">合格</a-select-option>
                <a-select-option  value="1">不合格</a-select-option>
                <a-select-option  value="2">暂停投标使用</a-select-option>
                <a-select-option  value="3">拉黑</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
import pick from 'lodash.pick'

// 表单字段
const fields = ['subcontractors', 'statusCode']

export default {
  name:'a'+Date.now(),
  props: {
    visible: {
      type: Boolean,
      required: true
    },
    loading: {
      type: Boolean,
      default: () => false
    },
    model: {
      type: Object,
      default: () => null
    }
  },
  data () {
    this.formLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 7 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 13 }
      }
    }
    return {
      companyNames: [], // 分公司名称
      projectNames: [], // 项目名称
      form: this.$form.createForm(this)
    }
  },
  created () {

    // 防止表单未注册
    fields.forEach(v => this.form.getFieldDecorator(v))

    // 当 model 发生改变时，为表单设置值
    this.$watch('model', () => {
      this.model && this.form.setFieldsValue(pick(this.model, fields))
    })
  },
  methods:{


  }
}
</script>
